'''
* This is the projet for Brtc LlmOps Platform
* @Author Leon-liao <liaosiliang@alltman.com>
* @Description //TODO 
* @File: module.py
* @Time: 2025/11/6
* @All Rights Reserve By Brtc
'''
from flask import Flask
from flask_login import LoginManager
from flask_migrate import Migrate
from flask_weaviate import FlaskWeaviate
from injector import Module, Binder, Injector
from redis import Redis

from internal.extension.database_extension import db
from internal.extension.login_extension import login_manager
from internal.extension.migrate_extension import migrate
from internal.extension.redis_extension import redis_client
from internal.extension.weaviate_extension import weaviate
from pkg.sqlalchemy import SQLAlchemy


class ExtensionModule(Module):
    #扩展模块注入 格式  类型<--binding-->实例
    def configure(self, binder:Binder):
        binder.bind(SQLAlchemy, to = db)
        binder.bind(Migrate, to = migrate)
        binder.bind(Redis, to = redis_client)
        binder.bind(FlaskWeaviate, to = weaviate)
        binder.bind(LoginManager, to = login_manager)

#全局的对象存储容器
app_injector = Injector([ExtensionModule])